### GENERATING TABLE B.4: LIST EXPERIMENT CONDITIONAL ON ASPIRATION-ABILITY GAP

### USES PNAS DATASET

### REQUIRED PACKAGES
require(multiwayvcov)
require(lmtest)
require(stargazer)

#running conditional models with pnas

#working under the table
work.gap.aspab <- lm(worklist.pre ~ worklist.pre.dum + aspab.gap + worklist.pre.dum*aspab.gap 
                     + male + age + education + income.imp + freq.help.net + factor(parish), 
                     data= pnas)

summary(work.gap.aspab)


##generating clustered standard errors
work.gap.aspab.clust<-cluster.vcov(work.gap.aspab, pnas$ed.parish)
work.gap.aspab.mcse <- coeftest(work.gap.aspab, work.gap.aspab.clust)
work.gap.aspab.mcse
rownames(work.gap.aspab.mcse)[2] <- "Treat"
rownames(work.gap.aspab.mcse)[22] <- "Treat*Aspiration Ability Gap"


#entering with fake documents

enter.gap.aspab <- lm(enterlist.pre ~ enterlist.pre.dum + aspab.gap + enterlist.pre.dum*aspab.gap 
                      + male + age + education + income.imp + freq.help.net + factor(parish), 
                      data= pnas)

summary(enter.gap.aspab)

##generating clustered standard errors
enter.gap.aspab.clust<-cluster.vcov(enter.gap.aspab, pnas$ed.parish)
enter.gap.aspab.mcse <- coeftest(enter.gap.aspab, enter.gap.aspab.clust)
enter.gap.aspab.mcse
rownames(enter.gap.aspab.mcse)[2] <- "Treat"
rownames(enter.gap.aspab.mcse)[22] <- "Treat*Aspiration Ability Gap"

##table of conditional effects

#for coefficients
stargazer(enter.gap.aspab.mcse, work.gap.aspab.mcse, align=TRUE, column.labels=c("Fake Documents", "Work as Tourist"), 
          omit.stat=c("LL","ser","f") ,single.row=FALSE)

#for n
stargazer(enter.gap.aspab, work.gap.aspab, align=TRUE, column.labels=c("Fake Documents", "Work as Tourist"), 
          omit.stat=c("LL","ser","f"), covariate.labels=c("Male", "Age", "Income", "Education", "Past Migration", "Past Visa Denial", "Network Migration"),title="Ability and Aspiration to Migrate",single.row=FALSE)
